package br.ufrj.dcc.ad.stats;

import java.util.Arrays;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import br.ufrj.dcc.ad.event.Event;

public abstract class Statistics {
	
	static Logger logger = LoggerFactory.getLogger(Statistics.class);
	
	private static List<Statistics> list;
	private String title;
	private String xLabel;
	private String yLabel;
	
	
	public Statistics() {
	}
	
	public Statistics(String title, String xLabel, String yLabel) {
		this.setTitle(title);
		this.setxLabel(xLabel);
		this.setyLabel(yLabel);
	}
	
	public static void start(Statistics... statistics) {
		list = Arrays.asList(statistics);
	}
	
	public static void finish() {
		for (Statistics s : list) {
			s.finishStatistic();
		}
	}
	
	public static void collect(Event event)  {
		for (Statistics s : list) {
			s.doStatistic(event);
		}
	}
	
	protected abstract void doStatistic(Event event);
	
	protected abstract void finishStatistic();

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getxLabel() {
		return xLabel;
	}

	public void setxLabel(String xLabel) {
		this.xLabel = xLabel;
	}

	public String getyLabel() {
		return yLabel;
	}

	public void setyLabel(String yLabel) {
		this.yLabel = yLabel;
	}

}
